<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="/web/libs/bootstrap/4.0/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/web/libs/bootstrap/4.0/css/dashboard.css" rel="stylesheet">
    <link rel="stylesheet" href="bootstrap-table.css">
</head>

<body>
<div id="header"></div>
<div class="container-fluid">
    <div class="row">
        <div id="menu"></div>
        <main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
            <div class="container">
                <div class="input-group">
                    股票代码：<input type="text" class="form-control" id="code">
                    股票名称：<input type="text" class="form-control" id="name">
                    所属行业：<input type="text" class="form-control" id="industry">
                    申万所属行业：<input type="text" class="form-control" id="sshy">
                </div>
                <div class="input-group">
                    公司亮点：<input type="text" class="form-control" id="gsld" value="">
                    概念关键字：<input type="text" class="form-control" id="conceptName" value="">
                    <span lass="input-group-btn"> <button class="btn btn-default" type="button" id="queryAction">Go!</button> </span>
                    <span lass="input-group-btn"> <button class="btn btn-default" type="button" id="downAction">Download!</button> </span>
                </div>
            </div>

            <div id="rptList" style="width: 100%; hight: 100%; float: left；">
                <table class="table table-hover" id="cusTable">
                </table>
            </div>
        </main>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/web/libs/js/jquery-3.1.1.slim.min.js"
        integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n"
        crossorigin="anonymous"></script>
<script src="/web/libs/js/tether.min.js"
        integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
        crossorigin="anonymous"></script>
<script src="/web/libs/bootstrap/4.0/js/bootstrap.min.js"></script>
<script src="/web/libs/js/common.js"></script>
<script src="/web/libs/js/jquery.js"></script>
<script src="/web/libs/js/dashboard/index.js"></script>
<script src="/web/libs/bootstrap/4.0/js/bootstrap-table.js"></script>
<script src="/web/libs/js/dashboard/basedata.js"></script>
<script type="text/javascript">
    $("#header").load("/web/header.html")
    addActive("m_basicFind");
    $('#cusTable').bootstrapTable('destroy').bootstrapTable({
        fixedColumns: true,
        fixedNumber: 1 //固定列数
    });
    $('#queryDate').val(new Date().format("yyyy"));

    function loadData() {
        $('#cusTable').bootstrapTable('destroy');
        $("#cusTable").bootstrapTable(
            {
                method: "get", //使用get请求到服务器获取数据
                url: "/web/basicFind/findList", //获取数据的Servlet地址
                striped: true, //表格显示条纹
                pagination: true, //启动分页
                cache: false,
                pageSize: 500, //每页显示的记录数
                //pageNumber:1, //当前第几页
                pageList: [10, 150, 500, 500], //记录数可选列表
                search: false, //是否启用查询
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                //showColumns: true,  //显示下拉框勾选要显示的列
                //showRefresh: true,  //显示刷新按钮
                sidePagination: "server", //表示服务端请求
                //设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
                //设置为limit可以获取limit, offset, search, sort, order
                queryParamsType: "undefined",
                queryParams: function queryParams(params) { //设置查询参数
                    var code = $('#code').val();
                    var name = $('#name').val();
                    var industry = $('#industry').val();
                    var sshy = $('#sshy').val();
                    var conceptName = $('#conceptName').val();
                    var gsld = $('#gsld').val();

                    var param = {
                        pageNum: params.pageNumber,
                        pageSize: params.pageSize,
                        sortName: params.sortName,      //排序列名
                        sortOrder: params.sortOrder //排位命令（desc，asc）
                    };
                    param.code = code;
                    param.name = name;
                    param.industry = industry;
                    param.sshy = sshy;
                    param.conceptName = conceptName;
                    param.gsld = gsld;
                    return param;
                },
                columns: [{
                    field: 'code',
                    title: '股票代码',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:open(\'http://basic.10jqka.com.cn/' + row.code + '\',\'' + row.code + '\')">' + value + '</a>';
                    }
                }, {
                    field: 'name',
                    title: '名称',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:open(\'http://data.eastmoney.com/hsgtcg/StockHdStatistics.aspx?stock=' + row.code + '\',\'' + row.code + '\')">' + value + '</a>';
                    }
                }, {
                    field: 'gsld',
                    title: '公司亮点',
                }, {
                    field: 'area',
                    title: '所在地域',
                }, {
                    field: 'industry',
                    title: '所属行业',
                }, {
                    field: 'sshy',
                    title: '申万所属行业',
                }, {
                    field: 'concept_name',
                    title: '相关概念',
                }, {
                    field: 'zxjj',
                    title: '最新解禁',
                }, {
                    field: 'zybl',
                    title: '质押比例',
                }, {
                    field: 'operate',
                    title: '估值/操作',
                    align: 'center',
                    events: "operateEvents",
                    formatter: operateFormatter
                }],
                responseHandler: function responseHandler(res) {

                    var s1 = JSON.stringify(res.result);
                    var s2 = '{"total":9999,"rows":' + s1 + '}';
                    //alert(s2);
                    return eval('(' + s2 + ')')
                },
                onLoadSuccess: function () { //加载成功时执行
                    $("#rptList").show();
                },
                onLoadError: function () { //加载失败时执行
                    alert("加载数据失败");
                }
            });
    }

    function operateFormatter(value, row, index) {
        return [
            '<button type="button" class="btnGUZHI btn btn-default  btn-sm">估值</button>'
        ].join('');
    }

    window.operateEvents = {
        'click .RoleOfD': function (e, value, row, index) {
            alert(row.code + "|" + row.UserName);
        },
        'click .btnGUZHI': function (e, value, row, index) {
            exportGUZHI(row.code, row.name);
        }
    };
    function exportGUZHI(code, name) {
        window.location.href = "/web/eastHsgtcg/downloadGuZhi?code=" + code + "&name=" + name;
    };

    $("#queryAction").click(function () {
        //alert("abc");
        loadData()
    });
    $("#downAction").click(function () {
        window.location.href="/web/fiveYearFinance/download?"
            + "queryDate ="+ $('#queryDate').val()
            + "&last5YearRoeAllPercent=" + $('#last5YearRoeAllPercent').val()
            + "&last5YearRoeAveragePercent=" + $('#last5YearRoeAveragePercent').val()
            + "&last1YearYsPercent=" + $('#last1YearYsPercent').val()
            + "&last3YearYsPercent=" + $('#last3YearYsPercent').val()
            + "&last1YearLrPercent=" + $('#last1YearLrPercent').val()
            + "&last3YearLrPercent=" + $('#last3YearLrPercent').val()
            + "&conceptName=" + $('#conceptName').val()
            + "&gsld=" + $('#gsld').val()
            + "&ysLrPassCount=" + $('#ysLrPassCount').val()
            + "&before10RoePlus=" + $('#before10RoePlus').is(":checked")
    });
    //loadData();
</script>
</body>
</html>
